<template>
  <div class="kawaii-comment-manage">
    <!-- 背景动画元素 -->
    <div class="animated-hearts">
      <div class="heart" v-for="n in 10" :key="n"></div>
    </div>

    <!-- 页面标题和筛选区域 -->
    <div class="kawaii-manage-header">
      <div class="header-title">
        <span>💬 动漫评论管理 💬</span>
      </div>
      <div class="header-filter">
        <div class="filter-type">
          <div class="type-item active">全部评论</div>
          <div class="type-item">最新评论</div>
          <div class="type-item">待回复</div>
          <div class="type-item">已回复</div>
        </div>
      </div>
    </div>

    <!-- 评论列表 -->
    <div class="kawaii-comment-list">
      <div class="list-header">
        <div class="header-cell user-cell">用户</div>
        <div class="header-cell video-cell">评论视频</div>
        <div class="header-cell content-cell">评论内容</div>
        <div class="header-cell time-cell">评论时间</div>
        <div class="header-cell operation-cell">操作</div>
      </div>

      <!-- 评论内容 -->
      <div v-if="animeComments.length > 0" class="comment-items">
        <div
          v-for="(comment, index) in animeComments"
          :key="index"
          class="comment-item"
        >
          <div class="user-cell">
            <div class="user-avatar">
              <img :src="comment.avatar" alt="用户头像" />
            </div>
            <div class="user-name">{{ comment.username }}</div>
          </div>
          <div class="video-cell">
            <div class="video-cover">
              <img :src="comment.videoCover" alt="视频封面" />
            </div>
            <div class="video-title">{{ comment.videoTitle }}</div>
          </div>
          <div class="content-cell">
            <div class="comment-content">{{ comment.content }}</div>
            <div class="comment-reactions" v-if="comment.reactions">
              <span class="reaction-item">
                <span class="reaction-icon">❤️</span>
                <span class="reaction-count">
                  {{ comment.reactions.likes }}
                </span>
              </span>
              <span class="reaction-item">
                <span class="reaction-icon">💬</span>
                <span class="reaction-count">
                  {{ comment.reactions.replies }}
                </span>
              </span>
            </div>
          </div>
          <div class="time-cell">{{ comment.time }}</div>
          <div class="operation-cell">
            <div class="operation-buttons">
              <button class="reply-btn">回复</button>
              <button class="pin-btn" v-if="comment.canPin">置顶</button>
              <button class="delete-btn">删除</button>
            </div>
          </div>
        </div>
      </div>

      <!-- 列表内容为空时的提示 -->
      <div v-else class="kawaii-empty-content">
        <img
          src="/src/assets/icons/empty-message.svg"
          alt="暂无内容"
          class="empty-icon bounce-animation"
        />
        <p class="empty-text">还没有收到评论呢~</p>
        <p class="empty-subtext">创作更多精彩内容，收获更多互动吧！</p>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'

// 动漫评论列表数据
const animeComments = ref([
  {
    username: '路飞控',
    avatar: '/src/assets/anime/avatar/avatar1.png',
    videoTitle: '海贼王：路飞的5档形态解析',
    videoCover: '/src/assets/anime/images/luffy.png',
    content:
      '太棒了！这个解析超详细，完全理解了路飞的5档形态原理！期待下一期分析香克斯的霸王色霸气~',
    time: '2023-12-18 14:23',
    reactions: {
      likes: 42,
      replies: 5,
    },
    canPin: true,
  },
  {
    username: '动漫迷日记',
    avatar: '/src/assets/anime/avatar/avatar2.png',
    videoTitle: '我的英雄学院：最新角色演示',
    videoCover: '/src/assets/anime/images/banner1.png',
    content: '新角色的设计太酷了！能力设定也很独特，期待在正片中的表现~',
    time: '2023-12-17 09:45',
    reactions: {
      likes: 28,
      replies: 3,
    },
    canPin: false,
  },
  {
    username: '咒术粉丝',
    avatar: '/src/assets/anime/avatar/avatar3.png',
    videoTitle: '咒术回战0：五条悟战斗分析',
    videoCover: '/src/assets/anime/images/banner2.png',
    content:
      '五条老师的领域展开太帅了！这个分析把每个细节都讲清楚了，特别是关于无下限术式的解释很到位！',
    time: '2023-12-15 21:37',
    reactions: {
      likes: 56,
      replies: 8,
    },
    canPin: true,
  },
  {
    username: '阿尼亚笑容保护协会',
    avatar: '/src/assets/anime/avatar/avatar4.png',
    videoTitle: '间谍过家家：阿尼亚的日常',
    videoCover: '/src/assets/anime/images/banner3.png',
    content:
      '阿尼亚真的太可爱了！waku waku~ 这个合集剪得超好，把所有经典场景都收录了。',
    time: '2023-12-12 18:05',
    reactions: {
      likes: 87,
      replies: 12,
    },
    canPin: true,
  },
  {
    username: '鬼灭刀客',
    avatar: '/src/assets/anime/avatar/avatar5.png',
    videoTitle: '鬼灭之刃：柱训练篇AMV',
    videoCover: '/src/assets/anime/images/banner1.png',
    content:
      'BGM选得真好，完美配合炎柱和水柱的战斗节奏！剪辑技术一流，转场很流畅！',
    time: '2023-12-10 15:42',
    reactions: {
      likes: 63,
      replies: 7,
    },
    canPin: false,
  },
])

onMounted(() => {
  // 页面加载时的初始化逻辑
  console.log('评论管理页面加载完成')
})
</script>

<style scoped lang="scss">
.kawaii-comment-manage {
  width: 100%;
  position: relative;
  padding: 15px;
  overflow: hidden;

  // 背景动画元素
  .animated-hearts {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;

    .heart {
      position: absolute;
      width: 10px;
      height: 10px;
      background-color: #ffb7c5;
      opacity: 0.4;
      pointer-events: none;
      transform: rotate(45deg);

      &:before,
      &:after {
        content: '';
        position: absolute;
        width: 10px;
        height: 10px;
        background-color: #ffb7c5;
        border-radius: 50%;
      }

      &:before {
        top: -5px;
        left: 0;
      }

      &:after {
        top: 0;
        left: -5px;
      }

      &:nth-child(1) {
        left: 10%;
        top: 10%;
        animation: float-heart 20s infinite linear;
        animation-delay: 1s;
        transform: rotate(45deg) scale(5px);
        opacity: 0.3;
      }

      &:nth-child(2) {
        left: 20%;
        top: 30%;
        animation: float-heart 25s infinite linear;
        animation-delay: 3s;
        transform: rotate(45deg) scale(7px);
        opacity: 0.2;
      }

      &:nth-child(3) {
        left: 30%;
        top: 50%;
        animation: float-heart 22s infinite linear;
        animation-delay: 5s;
        transform: rotate(45deg) scale(6px);
        opacity: 0.4;
      }

      &:nth-child(4) {
        left: 40%;
        top: 70%;
        animation: float-heart 28s infinite linear;
        animation-delay: 2s;
        transform: rotate(45deg) scale(8px);
        opacity: 0.3;
      }

      &:nth-child(5) {
        left: 50%;
        top: 20%;
        animation: float-heart 24s infinite linear;
        animation-delay: 0s;
        transform: rotate(45deg) scale(9px);
        opacity: 0.2;
      }

      &:nth-child(6) {
        left: 60%;
        top: 40%;
        animation: float-heart 26s infinite linear;
        animation-delay: 4s;
        transform: rotate(45deg) scale(5px);
        opacity: 0.3;
      }

      &:nth-child(7) {
        left: 70%;
        top: 60%;
        animation: float-heart 23s infinite linear;
        animation-delay: 1s;
        transform: rotate(45deg) scale(7px);
        opacity: 0.4;
      }

      &:nth-child(8) {
        left: 80%;
        top: 80%;
        animation: float-heart 27s infinite linear;
        animation-delay: 3s;
        transform: rotate(45deg) scale(6px);
        opacity: 0.2;
      }

      &:nth-child(9) {
        left: 90%;
        top: 25%;
        animation: float-heart 21s infinite linear;
        animation-delay: 2s;
        transform: rotate(45deg) scale(8px);
        opacity: 0.3;
      }

      &:nth-child(10) {
        left: 15%;
        top: 75%;
        animation: float-heart 29s infinite linear;
        animation-delay: 5s;
        transform: rotate(45deg) scale(6px);
        opacity: 0.4;
      }
    }
  }

  // 页面标题和筛选区域
  .kawaii-manage-header {
    margin-bottom: 25px;

    .header-title {
      margin-bottom: 20px;
      text-align: center;

      span {
        font-size: 22px;
        font-weight: 600;
        color: #ee6aa7;
        background: linear-gradient(45deg, #ee6aa7, #9370db);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
      }
    }

    .header-filter {
      .filter-type {
        display: flex;
        justify-content: center;
        border-bottom: 2px solid #f8bbd0;

        .type-item {
          padding: 12px 20px;
          font-size: 15px;
          color: #9e9e9e;
          cursor: pointer;
          position: relative;
          transition: all 0.3s;
          border-radius: 8px 8px 0 0;

          &:hover {
            color: #ee6aa7;
            background-color: rgba(255, 183, 197, 0.1);
          }

          &.active {
            color: #ee6aa7;
            font-weight: 500;
            background-color: rgba(255, 183, 197, 0.2);

            &::after {
              content: '';
              position: absolute;
              bottom: -2px;
              left: 0;
              width: 100%;
              height: 3px;
              background: linear-gradient(to right, #ee6aa7, #9370db);
              border-radius: 3px;
            }
          }
        }
      }
    }
  }

  // 评论列表
  .kawaii-comment-list {
    background-color: rgba(255, 255, 255, 0.85);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(236, 64, 122, 0.1);
    transition: all 0.3s;

    &:hover {
      box-shadow: 0 8px 25px rgba(236, 64, 122, 0.15);
    }

    .list-header {
      display: flex;
      height: 50px;
      background-color: rgba(246, 187, 208, 0.3);
      border-bottom: 2px solid #fce4ec;

      .header-cell {
        display: flex;
        align-items: center;
        padding: 0 16px;
        font-size: 15px;
        color: #ec407a;
        font-weight: 500;
      }

      .user-cell {
        flex: 1;
      }

      .video-cell {
        flex: 2;
      }

      .content-cell {
        flex: 3;
      }

      .time-cell {
        flex: 1;
      }

      .operation-cell {
        flex: 1;
      }
    }

    // 评论项目
    .comment-items {
      .comment-item {
        display: flex;
        padding: 15px 0;
        border-bottom: 1px solid #fce4ec;
        transition: all 0.3s;

        &:hover {
          background-color: rgba(252, 228, 236, 0.3);
          transform: translateY(-2px);
        }

        .user-cell {
          flex: 1;
          display: flex;
          flex-direction: column;
          align-items: center;
          padding: 0 16px;

          .user-avatar {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            overflow: hidden;
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
            margin-bottom: 8px;
            border: 3px solid rgba(255, 183, 197, 0.5);

            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
              transition: transform 0.3s;
            }

            &:hover img {
              transform: scale(1.1);
            }
          }

          .user-name {
            font-size: 14px;
            color: #333;
            font-weight: 500;
            text-align: center;
            max-width: 90px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }
        }

        .video-cell {
          flex: 2;
          display: flex;
          align-items: center;
          padding: 0 16px;

          .video-cover {
            width: 80px;
            height: 45px;
            border-radius: 6px;
            overflow: hidden;
            box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);

            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
              transition: transform 0.3s;
            }

            &:hover img {
              transform: scale(1.05);
            }
          }

          .video-title {
            margin-left: 10px;
            font-size: 14px;
            color: #616161;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            max-width: 140px;
          }
        }

        .content-cell {
          flex: 3;
          display: flex;
          flex-direction: column;
          justify-content: center;
          padding: 0 16px;

          .comment-content {
            font-size: 14px;
            color: #424242;
            line-height: 1.5;
            margin-bottom: 8px;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;

            &:hover {
              -webkit-line-clamp: unset;
              max-height: 200px;
              overflow-y: auto;
            }
          }

          .comment-reactions {
            display: flex;

            .reaction-item {
              display: flex;
              align-items: center;
              margin-right: 12px;

              .reaction-icon {
                font-size: 14px;
                margin-right: 4px;
              }

              .reaction-count {
                font-size: 13px;
                color: #9e9e9e;
              }
            }
          }
        }

        .time-cell {
          flex: 1;
          display: flex;
          align-items: center;
          padding: 0 16px;
          color: #9e9e9e;
          font-size: 14px;
        }

        .operation-cell {
          flex: 1;
          display: flex;
          align-items: center;
          padding: 0 16px;

          .operation-buttons {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;

            button {
              padding: 6px 12px;
              border: none;
              border-radius: 20px;
              font-size: 13px;
              cursor: pointer;
              transition: all 0.3s;
              margin: 3px;

              &.reply-btn {
                background-color: rgba(41, 182, 246, 0.2);
                color: #29b6f6;
                border: 1px solid rgba(41, 182, 246, 0.3);

                &:hover {
                  background-color: rgba(41, 182, 246, 0.3);
                  transform: translateY(-2px);
                }
              }

              &.pin-btn {
                background-color: rgba(156, 39, 176, 0.2);
                color: #9c27b0;
                border: 1px solid rgba(156, 39, 176, 0.3);

                &:hover {
                  background-color: rgba(156, 39, 176, 0.3);
                  transform: translateY(-2px);
                }
              }

              &.delete-btn {
                background-color: rgba(236, 64, 122, 0.2);
                color: #ec407a;
                border: 1px solid rgba(236, 64, 122, 0.3);

                &:hover {
                  background-color: rgba(236, 64, 122, 0.3);
                  transform: translateY(-2px);
                }
              }
            }
          }
        }
      }
    }

    // 空状态
    .kawaii-empty-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 60px 0;
      background: linear-gradient(
        135deg,
        rgba(252, 228, 236, 0.6) 0%,
        rgba(243, 229, 245, 0.6) 100%
      );

      .empty-icon {
        width: 160px;
        height: 160px;
        opacity: 0.8;
        margin-bottom: 16px;
        filter: hue-rotate(300deg) saturate(1.5);

        &.bounce-animation {
          animation: bounce 2s ease-in-out infinite alternate;
        }
      }

      .empty-text {
        font-size: 18px;
        color: #ec407a;
        margin-bottom: 8px;
      }

      .empty-subtext {
        font-size: 14px;
        color: #9e9e9e;
      }
    }
  }
}

// 动画关键帧
@keyframes float-heart {
  0% {
    transform: rotate(45deg) scale(1) translate(0, 0);
    opacity: 0.4;
  }

  25% {
    opacity: 0.6;
  }

  50% {
    transform: rotate(60deg) scale(1.1) translate(10px, 10px);
    opacity: 0.2;
  }

  75% {
    opacity: 0.4;
  }

  100% {
    transform: rotate(45deg) scale(1) translate(0, 0);
    opacity: 0.4;
  }
}

@keyframes bounce {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(-10px);
  }
}

// 响应式布局
@media screen and (max-width: 768px) {
  .kawaii-comment-manage {
    .kawaii-manage-header {
      .header-filter {
        .filter-type {
          overflow-x: auto;
          white-space: nowrap;
          justify-content: flex-start;

          &::-webkit-scrollbar {
            display: none;
          }

          .type-item {
            padding: 12px 15px;
            font-size: 14px;
          }
        }
      }
    }

    .kawaii-comment-list {
      .list-header {
        .header-cell {
          padding: 0 8px;
          font-size: 13px;
        }

        .video-cell,
        .time-cell {
          display: none;
        }

        .user-cell {
          flex: 1;
        }

        .content-cell {
          flex: 2;
        }
      }

      .comment-items {
        .comment-item {
          .video-cell,
          .time-cell {
            display: none;
          }

          .user-cell {
            flex: 1;
          }

          .content-cell {
            flex: 2;
          }
        }
      }
    }
  }
}
</style>
